#!/bin/bash

# config
#
local_repos_path=${LOCAL_TOOL_PATH:="/h/devworks/win_file_format_conv"}

if [ "$#" != "1" ]; then
    echo "$0 试卷目录路径"
    exit 1
fi

exam_papers_path="$(cygpath -u "$1")"

# stdin input requirement:
# student id, student name, score
# cut -f 1,2,10 exam_paper_scores.txt |
#
# mkdir -p 01.学生试卷

< /dev/stdin awk -f ${local_repos_path}/pick3.awk \
    | tee /dev/stdout | grep -v -E "^$" |cut -f 1 \
    | xargs -I{} rsync -av  "${exam_papers_path}/{}" ./01.学生试卷

